﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HuynhQuangWebsite.Models;
using THS.HtmlHelpers;

namespace HuynhQuangWebsite.Controllers
{
    public class Doi_tacController : Controller
    {
        //
        // GET: /PartnerPage/

        readonly huynhquangco_websiteEntities ctx = new huynhquangco_websiteEntities();
        public int PageSize = 6;
        public ActionResult Danh_sach(int page = 1)
        {
            var model = new HomeListViewModel();
            IList<Customer> customers = ctx.Customers.Where(p => p.CustomerIsVisible).OrderByDescending(p=>p.CustomerTypical).ToList();
            model.CustomerList = customers.Skip((page-1) * PageSize).Take(PageSize).ToList();
            model.CustomerInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = customers.Count() };
            return View(model);
        }

        public ActionResult Paging(int page = 1)
        {
            var model = new HomeListViewModel();
            IList<Customer> customers = ctx.Customers.Where(p => p.CustomerIsVisible).OrderByDescending(p => p.CustomerTypical).ToList();
            model.CustomerList = customers.Skip((page - 1) * PageSize).Take(PageSize).ToList();
            model.CustomerInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = customers.Count() };
            return PartialView("UCPartnerList", model);
        }
    }
}
